Compares with another object of T
Syntax
Visual Basic (Declaration) | |
---|
Public MustOverride Function CompareTo( _
ByVal other As T _
) As Integer |
Parameters
- other
Example
Library/Library.Test/TestPasswordHash.cs
C# | Copy Code |
---|
using (PasswordHash pwd1 = new PasswordHash(TEST_PASSWORD))
using (PasswordHash pwd2 = new PasswordHash(TEST_PASSWORD, pwd1.Salt))
{
Assert.AreEqual(pwd1, pwd2);
Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray());
Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray());
Assert.IsTrue(pwd1 == pwd2);
Assert.IsTrue(pwd1 == pwd2);
Assert.IsFalse(pwd1 != pwd2);
Assert.IsTrue(pwd1.Equals(pwd2));
Assert.IsTrue(pwd1.Equals((object)pwd2));
Assert.AreEqual(0, pwd1.CompareTo(pwd2));
Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode());
Assert.AreEqual(pwd1.ToString(), pwd2.ToString());
PasswordHash nil = null;
Assert.IsFalse(pwd1 < nil);
Assert.IsTrue(pwd1 > nil);
Assert.AreEqual(1, pwd1.CompareTo(null));
} |
VB.NET | Copy Code |
---|
Using pwd1 As New PasswordHash(TEST_PASSWORD)
Using pwd2 As New PasswordHash(TEST_PASSWORD, pwd1.Salt)
Assert.AreEqual(pwd1, pwd2)
Assert.AreEqual(pwd1.Salt.ToArray(), pwd2.Salt.ToArray())
Assert.AreEqual(pwd1.ToArray(), pwd2.ToArray())
Assert.IsTrue(pwd1 = pwd2)
Assert.IsTrue(pwd1 = pwd2)
Assert.IsFalse(pwd1 <> pwd2)
Assert.IsTrue(pwd1.Equals(pwd2))
Assert.IsTrue(pwd1.Equals(DirectCast(pwd2, Object)))
Assert.AreEqual(0, pwd1.CompareTo(pwd2))
Assert.AreEqual(pwd1.GetHashCode(), pwd2.GetHashCode())
Assert.AreEqual(pwd1.ToString(), pwd2.ToString())
Dim nil As PasswordHash = Nothing
Assert.IsFalse(pwd1 < nil)
Assert.IsTrue(pwd1 > nil)
Assert.AreEqual(1, pwd1.CompareTo(Nothing))
End Using
End Using |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also